package com.itheima.controller;

import com.itheima.pojo.User;
import org.springframework.web.bind.annotation.*;

/**
 * @author Xiao
 * @date 2021/9/14
 */
//@Controller
//@ResponseBody
@RestController // 相当于 @Controller + @ResponseBody
@RequestMapping("/easyBooks")
public class EasyBookController {

    //@RequestMapping(method = RequestMethod.POST)
    @PostMapping
    public String save(@RequestBody User user) {
        System.out.println("BookController save user --> " + user);
        return "save";
    }

    //@RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    @DeleteMapping("/{id}")
    public String delete(@PathVariable Integer id) {
        System.out.println("BookController delete id --> " + id);
        return "delete";
    }

    //@RequestMapping(method = RequestMethod.PUT)
    @PutMapping
    public String update(@RequestBody User user) {
        System.out.println("BookController update user --> " + user);
        return "update";
    }

    //@RequestMapping(method = RequestMethod.GET)
    @GetMapping
    public String queryAll() {
        System.out.println("BookController queryAll...");
        return "queryAll";
    }

    //@RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @GetMapping("/{id}")
    public String queryById(@PathVariable("id") Integer bookId) {
        System.out.println("BookController queryById id --> " + bookId);
        return "queryById";
    }
}
